﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/WorkflowManage/Workflownode/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                {
                    label: '所属工作流', name: 'wfid', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        $.ajax({
                            url: "/WorkflowManage/Workflownode/GetSelectJson",
                            data: { keyValue: cellvalue },
                            dataType: "json",
                            async: false,
                            success: function (data) {
                                cellvalue = data[0].text;
                            }
                        });
                        return cellvalue;
                    }
                },
                { label: '节点名称', name: 'wfnodename', width: 150, align: 'left' },
                { label: '节点描述', name: 'wfnodememo', width: 150, align: 'left' },
                { label: '节点开始时间', name: 'wfnodebegintime', width: 150, align: 'left' },
                { label: '节点结束时间', name: 'wfnodeendtime', width: 150, align: 'left' },
                {
                    label: '节点状态', name: 'wfnodestatus', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "启用" : "未启用";
                    }
                },
                {
                    label: '锁定状态', name: 'wfnodelock', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "锁定" : "未锁定";
                    }
                }
            ],
            pager: "#gridPager",
            sortname: 'id asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增节点",
            url: "/WorkflowManage/Workflownode/Form",
            width: "700px",
            height: "510px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Form",
            title: "修改节点",
            url: "/WorkflowManage/Workflownode/Form?keyValue=" + keyValue,
            width: "700px",
            height: "510px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/WorkflowManage/Workflownode/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Details",
            title: "查看节点",
            url: "/WorkflowManage/Workflownode/Details?keyValue=" + keyValue,
            width: "700px",
            height: "510px",
            btn: null,
        });
    }
    function btn_copyandpaste() {
        $.deleteForm({
            url: "/WorkflowManage/Workflownode/copyAndPasteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
         <div class="btn-group">
        <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建工作流节点</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">@*authorize="yes"*@
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit"  onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改节点</a></li>
                <li><a id="NF-delete"  onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除节点</a></li>
                <li><a id="NF-Details"  onclick="btn_details()"><i class="fa fa-search-plus"></i>查看节点</a></li>
@*                <li><a id="NF-copyAndPaste"  onclick="btn_copyandpaste()"><i class="fa fa-search-plus"></i>复制粘贴</a></li>*@
            </ul>
            <a href="javascript:;" class="close"></a> 
        </div>
        @*<script>$('.toolbar').authorizeButton()</script>*@
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="节点名称" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
